import BaseEntity from '../../BaseEntity'

export default class Goods<T> extends BaseEntity<T> {
    public url = this.options.baseURL + 'api/v1/goods'

    constructor(data?: T) {
        super(data!)
    }

    async getGoodsDetails(goodsId: string) {
        return await this.getInstance()
            .get(`${this.url}/${goodsId}/details`)
            .then(res => {
                return res.data
            })
    }

    async getGoods(p: number = 0, n: number = 9) {
        return await this.getInstance()
            .get(`${this.url}?p=${p}&n=${n}`)
            .then(res => {
                return res.data
            })
    }
}
